﻿@using LotteryVoteMVC.Core.Application
@using LotteryVoteMVC.Core
@using LotteryVoteMVC.Models
@using LotteryVoteMVC.Resources
@using LotteryVoteMVC.Utility
@model PagedList<BetAutoDropWater>
@{
    ViewBag.Title = "BetAuto";
    Layout = "~/Views/Shared/Main.cshtml";
}
@section Header
{
    <script src="@Url.Content("~/Scripts/Customer/TableBase.js")" type="text/javascript"></script>
    <link href="@Url.Content("~/Content/TableBase.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/inputs.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/Pager/pagerGray.css")" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $(function () {
            $('form').submit(function (e) {
                if (this.method.toLowerCase() == "get") {
                    var data = $(this).serialize();
                    var url = this.action;
                    if (!isNullOrEmpty(data))
                        data += "&Search=true";
                    visit(url, data, true);
                    return false;
                }
            });
        });

        $(document).ready(function () {
            bindSearchValue();
            $("#add").bind("click", function () {
                $("form").attr("method", "post").attr("action", "/DropWater/AddBetAuto");
            });
        });
        var bindSearchValue = function () {
            var url = decodeURIComponent(document.URL);
            if (url.indexOf("?") > 0) {
                //获取所有参数对值
                var queryString = url.substr(url.indexOf("?") + 1, url.length);
                //分组
                var queryStringArr = queryString.split("&");
                $(queryStringArr).each(function (i, param) {
                    var paramInfo = param.split("=");
                    var ele = $("#searchBar #{0}".format(paramInfo[0]));
                    if (ele.length) {
                        ele.val(paramInfo[1]);
                    }
                });
            }
        }
    </script>
}
@{int index = 1;}
<div id="searchBar">
    @using (Html.BeginForm("BetAuto", "DropWater", FormMethod.Get))
    {
        <span>@Resource.CompanyType</span>
        <select id="CompanyType" name="CompanyType">
            <option value="0">@Resource.All</option>
            @foreach (var ct in EnumHelper.GetDescription<CompanyType>())
            { 
                <option value="@ct.Value">@ct.Description</option>                
            }
        </select>
        <span>@Resource.GameType</span>
        @Html.Partial("~/Views/Partial/GamePlayWay.cshtml", LotterySystem.Current.GamePlayWays)
        <span>@Resource.Amount</span>
        @Html.TextBox("Amount")
        @Html.ValidationMessage("Amount");
        <span>@Resource.DropWater</span>
        @Html.TextBox("DropWater")
        @Html.ValidationMessage("DropWater");
        <input type="submit" name="search" id="search" value="@Resource.Search" />
        <input type="submit" name="add" id="add" value="@Resource.Add" />
    }
    @Html.ValidationMessage("Success")
</div>
<table cellpadding="0" cellspacing="0">
    <thead>
        <tr>
            <td colspan="7">
                @Resource.BatterBetLimit
            </td>
        </tr>
        <tr>
            <td>
                @Resource.No
            </td>
            <td>
                @Resource.CompanyType
            </td>
            <td>
                @Resource.GameType
            </td>
            <td>
                @Resource.Amount
            </td>
            <td>
                @Resource.DropWater
            </td>
            <td>
                @Resource.Time
            </td>
            <td>
                @Resource.Function
            </td>
        </tr>
    </thead>
    <tbody>
        @foreach (var drop in Model)
        { 
            <tr>
                <td>
                    @(index++)
                </td>
                <td>
                    @drop.CompanyType.GetDesc()
                </td>
                <td>
                    @Extended.GetGPWDescription(drop.GamePlayWayId)
                </td>
                <td>
                    @drop.Amount.ToString("N")
                </td>
                <td>
                    @drop.DropValue
                </td>
                <td>
                    @drop.CreateTime
                </td>
                <td>
                    @Html.ActionLink(Resource.Delete, "RemoveBetAuto", new { Id = drop.BetDropId }, new { onclick = "return confirm('Are you sure?')" })
                </td>
            </tr>
        }
    </tbody>
</table>
@Html.Pager(Model)
